// Below, you can choose from either using global form styles or class-driven
// form styles. By default, the global styles are on.

%form {
	ul {
		margin: 0;
		padding: 0;
		list-style: none;
	}
}

%form-field {
	margin: 0;
	padding: 7px 14px;
	width: 100%;
	color: $gray-dark;
	font-size: 16px;
	line-height: 1.5;
	border: 1px solid lighten( $gray, 20% );
	background-color: $white;
	transition: all .15s ease-in-out;
	box-sizing: border-box;

	&::placeholder {
		color: $gray;
	}

	&:hover {
		border-color: lighten( $gray, 10% );
	}

	&:focus {
		border-color: $blue-wordpress;
		outline: none;
		box-shadow: 0 0 0 2px $blue-light;

		&::-ms-clear {
			display: none;
		}
	}

	&:disabled {
		background: $gray-light;
		border-color: lighten( $gray, 30% );
		color: lighten( $gray, 10% );
		opacity: 1;
		-webkit-text-fill-color: lighten( $gray, 10% );

		&:hover {
			cursor: default;
		}

		&::placeholder {
			color: lighten( $gray, 10% );
		}
	}
}

%textarea {
	min-height: 92px;
}


// ==========================================================================
// Global form elements
// ==========================================================================

form {
	@extend %form;
}
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type=checkbox],
input[type=radio],
input[type="tel"],
input[type="url"],
textarea {
	@extend %form-field;
}
textarea {
	@extend %textarea;
}

fieldset,
input[type="text"],
input[type="search"],
input[type="email"],
input[type="number"],
input[type="password"],
input[type="tel"],
input[type="url"],
textarea,
select,
label {
	box-sizing: border-box;
}

/*Checkbooms*/

input[type=checkbox],
input[type=radio] {
	clear: none;
	cursor: pointer;
	display: inline-block;
	line-height: 0;
	height: 16px;
	margin: 2px 0 0;
	float: left;
	outline: 0;
	padding: 0;
	text-align: center;
	vertical-align: middle;
	width: 16px;
	min-width: 16px;
	appearance: none;
}

input[type=checkbox] + span,
input[type=radio] + span {
	display: block;
	margin-left: 24px;
}

input[type=checkbox] {
	&:checked:before {
		@include clear-text;

		content: '\f418';
		margin: -4px 0 0 -5px;
		float: left;
		display: inline-block;
		vertical-align: middle;
		width: 16px;
		font: 400 23px/1 Noticons;
		speak: none;
		color: $blue-medium;
	}
	&:disabled:checked:before {
		color: lighten( $gray, 10% );
	}
}

input[type=radio] {
	border-radius: 50%;
	margin-right: 4px;
	line-height: 10px;

	&:checked:before {
		float: left;
		display: inline-block;
		content: '\2022';
		margin: 3px;
		width: 8px;
		height: 8px;
		text-indent: -9999px;
		background: $blue-medium;
		vertical-align: middle;
		border-radius: 50%;
		animation: grow .2s ease-in-out;
	}

	&:disabled:checked:before {
		background: lighten( $gray, 30% );
	}
}

@keyframes grow {
	0% {
		transform: scale(0.3);
	}

	60% {
		transform: scale(1.15);
	}

	100% {
		transform: scale(1);
	}
}

@keyframes grow {
	0% {
		transform: scale(0.3);
	}

	60% {
		transform: scale(1.15);
	}

	100% {
		transform: scale(1);
	}
}

/* end checkbooms */


select {
	background: $white url() no-repeat right 10px center;
	border-color: lighten( $gray, 20% );
	border-style: solid;
	border-radius: 4px;
	border-width: 1px 1px 2px;
	color: $gray-dark;
	cursor: pointer;
	display: inline-block;
	margin: 0;
	outline: 0;
	overflow: hidden;
	font-size: 14px;
	font-weight: 700;
	text-overflow: ellipsis;
	text-decoration: none;
	vertical-align: top;
	white-space: nowrap;
	box-sizing: border-box;
	padding: 7px 32px 9px 14px; // Aligns the text to the 8px baseline grid and adds padding on right to allow for the arrow.
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;

	&:hover {
		background-image: url();
	}

	&:focus {
		background-image: url();
		border-color: $blue-medium;
		box-shadow: 0 0 0 2px $blue-light;
		outline: 0;
		-moz-outline:none;
		-moz-user-focus:ignore;
	}

	&:disabled,
	&:hover:disabled {
		background: url() no-repeat right 10px center;;
	}

	// A smaller variant that works well when presented inline with text
	&.is-compact {
		min-width: 0;
		padding: 0 20px 2px 6px;
		margin: 0 4px;
		background-position:  right 5px center;
		background-size: 12px 12px;
	}

	// Make it display:block when it follows a label
	label &,
	label + & {
		display: block;
		min-width: 200px;

		&.is-compact {
			display: inline-block;
			min-width: 0;
		}
	}

	// IE: Remove the default arrow
	&::-ms-expand {
		display: none;
	}

	// IE: Remove default background and color styles on focus
	&::-ms-value {
		background: none;
		color: $gray-dark;
	}

	// Firefox: Remove the focus outline, see http://stackoverflow.com/questions/3773430/remove-outline-from-select-box-in-ff/18853002#18853002
	&:-moz-focusring {
		color: transparent;
		text-shadow: 0 0 0 $gray-dark;
	}
}

/*Search Inputs*/
input[type="search"]::-webkit-search-decoration {
	// We don't use the native results="" UI
	// Ensures the input text is flush to the start of the element, as in regular text inputs
	// See, for example, http://geek.michaelgrace.org/2011/06/webkit-search-input-styling/
	display: none;
}
